package com.gzhryc.test;

import com.gzhryc.jdbc.ConnectionFactory;
import com.gzhryc.jdbc.models.ConnectInfo;
import org.apache.log4j.xml.DOMConfigurator;
import org.junit.AfterClass;
import org.junit.BeforeClass;

import java.util.Properties;

public class JunitInitial {

    /**
     * @BeforeClass:这个注解表示这个方法会在所有测试方法执行之前执行
     * 因为是static修饰的静态方法，所有只会执行一次。通常用来进行一些
     * 资源的加载
     */
    @BeforeClass
    public static void setUpBeforeClass() throws Exception {

        DOMConfigurator.configure(JunitInitial.class.getClassLoader().getResource("log4j.xml"));

        Properties properties = new Properties();
        properties.load(JunitInitial.class.getResourceAsStream("/jdbc/jdbc10021.properties"));
        ConnectInfo read = new ConnectInfo(properties);

        ConnectionFactory.addDataSource("read_31",read);

        properties.load(JunitInitial.class.getResourceAsStream("/jdbc/jdbc10022.properties"));
        ConnectInfo write = new ConnectInfo(properties);


        ConnectionFactory.addDataSource("write_1",write);


    }

    /**
     * @AfterClass:这个注解表示这个方法会在所有方法执行完毕之后执行，通常用来释放资源
     * @throws Exception
     */
    @AfterClass
    public static void tearDownAfterClass() throws Exception {

    }
}
